import { Model } from 'mongoose';
import { Injectable, ForbiddenException } from '@nestjs/common';
import { InjectModel, InjectConnection } from '@nestjs/mongoose';
import { User, UserDocument } from './schemas/user.schema';

@Injectable()
export class UserService {
  constructor(@InjectModel('User') private userModel: Model<UserDocument>) {}

  getName(id): string {
    return 'My name is Annie' + id;
  }

  async create(user) {
    // const createdUser = new this.userModel(user)
    // const existUser = await this.userModel.findOne({ workId: user.workId})
    // if (existUser) {
    //   throw new ForbiddenException('WorkId is exist');
    // }
    // return createdUser.save();
  }
}
